package com.example.controller;

import com.example.entity.LockDevice;
import com.example.entity.LockDeviceInfo;
import com.example.service.LockAlarmService;
import com.example.service.LockCountyService;
import com.example.service.LockDeviceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ys")
public class ProjectController {
    @Autowired
    private LockAlarmService lockAlarmService;
    @Autowired
    private LockDeviceInfoService lockDeviceInfoService;
    @Autowired
    private LockCountyService lockCountyService;

    //获取所有设备
    @GetMapping("/getAllDevice")
    public Object getAllDevice() {
        return lockDeviceInfoService.getAllDevice();
    }

    //获取所有预警信息
    @GetMapping("/getAlarmList")
    private Object getAlarmList() {
        return lockAlarmService.getAlarms();
    }

    //获取所有设备外加一条最新的预警信息
    @GetMapping("/getDeviceAndAlarm")
    private Object getDeviceAndAlarm() {
        return lockAlarmService.getDeviceAndAlarm();
    }
    //通过设备名搜索设备
    @PostMapping("/searchDevice")
    private Object searchDevice(@RequestBody LockDeviceInfo lockDeviceInfo) {
        return lockDeviceInfoService.selectDeviceByName(lockDeviceInfo);
    }

    //获取所有乡镇
    @GetMapping("/getAllCounty")
    public Object getAllCounty() {
        return lockCountyService.getAllCounty();
    }

    //通过乡镇id查询设备
    @PostMapping("/getDeviceByCountyId")
    public Object getDeviceByCountyId(@RequestBody LockDevice lockDevice) {
        return lockDeviceInfoService.selectDeviceByCountyId(lockDevice);
    }
}
